package com.springday2;

import com.springday2.dao.BookDao;
import com.springday2.dao.impl.BookDaoImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.Map;

public class AppForday2 {
    public static void main(String[] args) {

        Map<String, String> env = System.getenv();
        System.out.println(env);

        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContextForDay2.xml");

//        druid
//        DataSource dataSource = (DataSource) ctx.getBean("dataSource");
//        System.out.println("dataSource" + dataSource);

//        c3p0
//        DataSource dataSource = (DataSource) ctx.getBean("dataSourceC3p0");
//        System.out.println("dataSource" + dataSource);

        BookDao bookDao = (BookDao) ctx.getBean("bookDao");
        bookDao.save();
    }
}
